﻿<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
    xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>
        Create Custom Folder Item
      </Title>
    </Header>
    <Snippet>
      <Code Language="CSharp">
        <![CDATA[
		private void CreateCustomFolder()
		{
			Outlook.MAPIFolder inBox = (Outlook.MAPIFolder)
				this.ActiveExplorer().Session.GetDefaultFolder
				(Outlook.OlDefaultFolders.olFolderInbox);
			string userName = (string)this.ActiveExplorer()
				.Session.CurrentUser.Name;
			Outlook.MAPIFolder customFolder = null;
			try
			{
				customFolder = (Outlook.MAPIFolder)inBox.Folders.Add(userName,
					Outlook.OlDefaultFolders.olFolderInbox);
				MessageBox.Show("You have created a new folder named " +
					userName + ".");
				inBox.Folders[userName].Display();
			}
			catch (Exception ex)
			{
				MessageBox.Show("The following error occurred: " + ex.Message);
			}
		}
		]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>